num1 = 10


def f():
    global num1  # 声明在f中使用的num1是全局变量num1
    num1 = 20
    print(num1)  # 20


f()
print(num1)  # 2
